import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-expire-query',
  templateUrl: './expire-query.component.html',
  styleUrls: ['./expire-query.component.scss']
})
export class ExpireQueryComponent implements OnInit {
  public accountList = [];
  
  public listCount = 10;

  constructor() { }

  ngOnInit() {
    this.accountList = [];
    let name = ['平安证券对冲1号','华泰证券对冲1号','谢子键']
    let isStop = ['是','否'];
    let examine = ['已通过','待审核','已终止'];
    for (var i = 1; i <= this.listCount; i++) {
      var random = Math.round(Math.random() * 2);
      var random_stop = Math.round(Math.random());
      this.accountList.push({
        // 账户编码、账户名称、运作日期、开始日期、到期日期
        code: '802173' + i,
        name: name[random],
        rundate:'2017-03-01',
        startdate:'2017-04-23',
        enddate:'2017-11-02',
        isStop: isStop[random_stop],
        examine:examine[random]
      });
    }

  }
  ngAfterViewInit() {
    //Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
    //Add 'implements AfterViewInit' to the class.
    window['$']('input').iCheck({
      checkboxClass: 'icheckbox_flat-blue',
      radioClass: 'iradio_flat-blue'
    });
    //全选、全反选
    window['$']('#checkAll').on('ifChecked ifUnchecked', function (event) {
      if (event.type == 'ifChecked') {
        window['$']('.subcb').iCheck('check');
      } else {
        window['$']('.subcb').iCheck('uncheck');
      }
    });

    window['$']('.subcb').on('ifChanged', function (event) {
      if (window['$']('.subcb').filter(':checked').length == window['$']('.subcb').length) {
        window['$']('#checkAll').prop('checked', 'checked');
      } else {
        window['$']('#checkAll').prop('checked', false);
      }
      window['$']('#checkAll').iCheck('update');
    });
  }
  xuyue(){
    window['$'](".modal-detail").modal('show');
  }
  zhongzhi(){
    window['$'](".modal-stop").modal('show');
  }
  showHisListModal() {
    window['$']("#detail-his-list-modal").modal();
  }
  stopCheck(){
    window['swal']({
      title: "Are you sure?",
      text: "Your will not be able to recover this imaginary file!",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "Yes, delete it!",
      cancelButtonText: "No, cancel plx!",
      closeOnConfirm: false,
      closeOnCancel: false
    },
    function(isConfirm){
      if (isConfirm) {
        window['swal']("Deleted!", "Your imaginary file has been deleted.", "success");
      } else {
        window['swal']("Cancelled", "Your imaginary file is safe :)", "error");
      }
    });
  }
}
